<script type="text/x-template" id="plus-nav-menu">
    <div style="margin-bottom: 30px;overflow: hidden">
        <el-container>
            <el-header>
                <!-- 顶部导航栏 -->
                <el-menu
                        :default-active="4"
                        class="el-menu-demo"
                        mode="horizontal"
                        background-color="#545c64"
                        text-color="#fff"
                        active-text-color="#ffd04b">
                    <el-submenu index="1" :key="1">
                        <template slot="title">常用服务管理</template>
                        <el-menu-item v-for="(item, index) in serviceInfo" index="getIndex('1',index)" @click="openWeb(item.url)">{{item.name}}
                        </el-menu-item>
                    </el-submenu>
                    <el-submenu index="2" :key="2">
                        <template slot="title">管理后台管理</template>
                        <el-menu-item index="2-1" @click="handleJumpUrl('/myExtend/kafkaView')">
                             Kafka管理
                        </el-menu-item>
                    </el-submenu>
                    <el-menu-item index="9" :key="9" @click="handleJumpUrl('/swagger-ui')">->Swagger2</el-menu-item>
                    <el-menu-item :disabled="disabledCodeGen" index="10" :key="10" @click="handleJumpUrl('/myExtend/codeGenView')">->代码生成</el-menu-item>
                </el-menu>
            </el-header>
        </el-container>
    </div>
</script>

<script>
    Vue.component('plus-nav-menu', {
        template: '#plus-nav-menu',
        data() {
            return {
                disabledCodeGen:true,
                serviceInfo:[],
                urls: {
                    getPlusConfigInfoUrl: '/myExtend/getPlusConfigInfo.html',
                }
            }
        },
        methods: {
            handleJumpUrl(url) {
                window.open(url + ".html");
            },
            getIndex(parentIndex, index){
                return parentIndex + "-" + index
            },
            openWeb(url) {
                window.open(url);
            },
            loadPlusConfigInfo(){
                this.ajax(this.urls.getPlusConfigInfoUrl, {
                }, function (result) {
                    if (result.code == 0) {
                        this.serviceInfo = result.data.serviceInfo
                        this.disabledCodeGen = !(result.data.localRunning === 1)
                    } else {
                        this.$message({
                            type: 'error',
                            message: result.msg
                        })
                    }
                }.bind(this))
            }
        },
        created() {
            this.loadPlusConfigInfo();
        }
    })
</script>